package org.example;

import java.util.UUID;

public class SessionManager {
    private RedisClient redisClient;

    public SessionManager(RedisClient redisClient) {
        this.redisClient = redisClient;
    }

//创建会话
    public String createSession(String userId) {
        String sessionId = UUID.randomUUID().toString();
        String sessionData = "userId:" + userId;
        redisClient.set(sessionId, sessionData);
        return sessionId;
    }

    public String getSession(String sessionId) {
        return redisClient.get(sessionId);
    }

    public void deleteSession(String sessionId) {
        redisClient.delete(sessionId);
    }
}
